<!-- 产品列表用户选择 -->
<template>
    <div style="height: 60vh;overflow-y: auto;">
       <el-table :data="items">
            <el-table-column
                prop="masterName"
                label="师傅姓名"
                />
            <el-table-column
                prop="masterHone"
                label="师傅电话"
                />
            <el-table-column
                label="报价"
                >
                <template slot-scope="data">
                    <span style="font-weight: bold;color: red;">{{ data.row.priceTotal }}</span>
                </template>
            </el-table-column>
            <el-table-column
                prop="createTime"
                label="报价时间"
                />
            <el-table-column
              prop="createTime"
              label="报价明细"
              v-if="isAdmin"
            >
              <template slot-scope="data">
                  <el-link type="success" @click="viewDetailHandle(data.row)">查看</el-link>
              </template>
            </el-table-column>

            <el-table-column label="操作" v-if="!isAdmin">
                <template slot-scope="data">
                    <el-button type="primary" size="mini" @click="takePriceHandle(data.row)">选择报价</el-button>
                </template>
            </el-table-column>
            
       </el-table>

       <!-- 报价明细 -->
       <el-dialog
        title="报价明细"
        :visible.sync="showPriceDetail"
        :append-to-body="true"
        width="60%"
        @close="">
        <PriceDetail :valueData="currentData"/>
    </el-dialog>
    

    </div>
  </template>
  
  <script>
    import Api from './api'
    import PriceDetail from "./price_detail.vue"
  export default {
    components: {
      PriceDetail,
    },
    props:['orderId', 'isAdmin'],
    data() {
      return {
        showPriceDetail:false,
        selectItem:{id:undefined},
        items:[],
        currentData:{itemList:[]},
      }
    },
    mounted() {
      this.netGetList();
    },
    beforeDestroy() {
      this.items = [];
    },
    methods:{
      async netGetList() {
        let self = this;
        var res = await Api.netYzOrderPriceGetList({"orderId":this.orderId})
        let {status,data,msg} = res.data;
        if(status == 200) {
          self.items = data;
        } else {
          this.$message({
            message: msg,
            type: 'error',
            showClose: true,
            duration: 3000,
          });
          
        }
      },
      /// 查看报价明细
      viewDetailHandle(data){
        console.log('viewDetailHandle', data)
        this.currentData = data;
        this.showPriceDetail = true;
      },

      /// 选择报价
      async takePriceHandle(data) {
      let info = data;
        let res = await Api.netYzOrderSelectPrice({
          id:this.orderId,
          orderPriceId:data.id
        });
        let {status,msg} = res.data;
        if(status == 200) {
          this.$message({
            message: '操作成功',
            type: 'success',
            showClose: true,
            duration: 3000,
          });
          this.$emit('dismissHandle')
        } else {
          this.$message({
            message: msg,
            type: 'error',
            showClose: true,
            duration: 3000,
          });
          
        }
      }
    },
  }
  </script>
  
  <style>
  .deleteBorder .el-tabs__nav-wrap::after{
      height: 0;
    }
  </style>
  